package com.xqboss.apps.domain.game;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.xqboss.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.util.Date;
import java.util.stream.Stream;

/**
 * <p>
 * 游戏商品表
 * </p>
 *
 * @author HaoLun
 * @since 2022-01-20
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value = "GameSpu对象", description = "游戏商品表")
@TableName("game_spu")
public class GameSpu extends BaseEntity {

//    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "游戏ID")
    private Long gameId;

    @ApiModelProperty(value = "分类ID")
    private String categoryId;

    @ApiModelProperty(value = "商品名称")
    private String title;

    @ApiModelProperty(value = "卖点描述")
    private String salePoint;

    @ApiModelProperty(value = "关键名称")
    private String keyTitle;

    @ApiModelProperty(value = "主图")
    private String mainImg;

    @ApiModelProperty(value = "详情图")
    private String detailImg;

    @ApiModelProperty(value = "售价")
    private BigDecimal price;

    @ApiModelProperty(value = "库存")
    private Integer stock;

    @ApiModelProperty(value = "返积分数量")
    private Integer returnIntegral;

    @ApiModelProperty(value = "积分抵现 元")
    private BigDecimal integralMoney;

    @ApiModelProperty(value = "单人限购")
    private Integer limitStock;

    @ApiModelProperty(value = "系统编码")
    private String systemCode;

    @ApiModelProperty(value = "自定义编码")
    private String selfCode;


    @ApiModelProperty(value = "自动发货 0关闭 1开启")
    private Integer autoDelivery;

    @ApiModelProperty(value = "权益标签")
    private String benefitsTags;

    @ApiModelProperty(value = "是否上架 0下架 1上架")
    private Integer isOnline;

    private Integer sort;


    @ApiModelProperty(value = "0 待填充 1待审核 2审核失败 3待上架 4售卖中 5已下架 6交易中 7已售")
    private Integer status;

    @ApiModelProperty(value = "用户id")
    private Long userId;

    private Integer verifyAfterStatus;

    private String verifyArticle;

    @ApiModelProperty(value = "提交状态 0待填充 1 待审核")
    private Integer submitStatus;

    @ApiModelProperty(value = "海报图")
    private String posterUrl;

    @ApiModelProperty(value = "是否已分发过QQ消息")
    private Integer isQqMsg;

    @JsonIgnore
    @TableLogic(value = "null", delval = "now()")
    protected Date deleteTime;


    public enum SpuStatusEnum {
        WAIT_FILL(0, "待填充", "待审核"),
        WAIT_CHECK(1, "待审核", "待审核"),
        FAIL(2, "审核失败", "审核失败"),
        WAIT_ONLINE(3, "待上架", "待上架"),
        ONLINE(4, "售卖中(已上架)", "售卖中"),
        OFF(5, "已下架", "已下架"),
        SALEING(6, "交易中", "交易中"),
        SALED(7, "已售", "已售"),
        WAIT_EVALUATE(8, "待估值", "已估值"),
        EVALUATE(9, "已估值", "待发布"),
        EVALUATE_AND_PUBLISH(10, "估值后并已发布", "待审核"),
        ;


        private int value;
        private String description;
        private String statusStr;

        SpuStatusEnum(int value, String description, String statusStr) {
            this.value = value;
            this.description = description;
            this.statusStr = statusStr;
        }

        public int getValue() {
            return value;
        }

        public String getStatusStr() {
            return statusStr;
        }

        public void setValue(int value) {
            this.value = value;
        }

        public static SpuStatusEnum toDesctiption(int value) {
            return Stream.of(SpuStatusEnum.values())
                    .filter(c -> c.value == value)
                    .findAny()
                    .orElse(null);
        }
    }


}
